package com.osti.mytest;

import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;

public class ActivityDarts extends FragmentActivity
{
	private int			m_NrPlayers;
	private int			m_NrGroups;
	private String		m_AddPlayers;
	

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
    	// Bundle for the information from "ActivityCntPlayers"
    	Bundle	h_BundleCntPlayers;
    	
    	
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.activity_groups);
    	
    	h_BundleCntPlayers = getIntent().getExtras();
        if(h_BundleCntPlayers != null)
        {
        	// get the following information from the Bundle:
        	// a) the number of players
        	m_NrPlayers		= h_BundleCntPlayers.getInt("key_NrPlayers");
        	// b) the numbers of groups
        	m_NrGroups		= h_BundleCntPlayers.getInt("key_NrGroups");
        	// c) the kind of adding players to the groups (manually / random)
        	m_AddPlayers	= h_BundleCntPlayers.getString("key_KindAddingPlayers");

        }
        
        //Starte Fragment
        startDarts();
    }
    
    private void startDarts()
    {
    	Fragment			h_Frag;
    	Bundle				h_Args;
    	FragmentTransaction	h_FragTrans;
    	
		h_Frag = getSupportFragmentManager().findFragmentByTag(Constants.FRAG_TAG_GRPMANUAL);
		if(h_Frag == null)
		{
			h_Frag = new FragDartsManual();
			h_Args = new Bundle();

			// add information
		  	h_Args.putInt(Constants.FRAG_KEY_PLAYERS, m_NrPlayers);
		  	h_Args.putInt(Constants.FRAG_KEY_GROUPS, m_NrGroups);
		  	h_Frag.setArguments(h_Args);
		  	
		  	// start fragment
		  	h_FragTrans = getSupportFragmentManager().beginTransaction();
		  	h_FragTrans.add(R.id.input_container, h_Frag, Constants.FRAG_TAG_GRPMANUAL);
		  	h_FragTrans.commit();
		 }
    }
    
//    private void addToGroupRandom()
//    {
//    	Fragment			h_Frag;
//    	Bundle				h_Args;
//    	FragmentTransaction	h_FragTrans;
//    	
//		h_Frag = getSupportFragmentManager().findFragmentByTag(Constants.FRAG_TAG_GRPRANDOM);
//		if(h_Frag == null)
//		{
//			h_Frag = new FragGrpRandom();
//			h_Args = new Bundle();
//
//			// add information
//		  	h_Args.putInt(Constants.FRAG_KEY_PLAYERS, m_NrPlayers);
//		  	h_Args.putInt(Constants.FRAG_KEY_GROUPS, m_NrGroups);
//		  	h_Frag.setArguments(h_Args);
//		  	
//		  	// start fragment
//		  	h_FragTrans = getSupportFragmentManager().beginTransaction();
//		  	h_FragTrans.add(R.id.input_container, h_Frag, Constants.FRAG_TAG_GRPRANDOM);
//		  	h_FragTrans.commit();
//		 }
//    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
